home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
admin
/
login
/
sac-1.000
/
sac-1
/
sac-1.3.1
/
scripts
/
check
next >
Wrap
Text File
|
1996-05-27
|
1KB
|
39 lines
#!/bin/sh
#
# Check checks to see if any of the people who are logged in at the time
# have used up their allotment of time (as specified by MAXHOURS) on the
# modems (as specified by TTYS).
#
MAXHOURS=4.25
#TTYS='ttyC0 ttyC1 ttyC2 ttyC3 ttyC4 ttyC5 ttyC6 ttyC7'
TTYS="tty1 tty2 tty3 tty4 tty5 tty6 ttyp0 ttyp1 ttyp2 ttyp3"
hours=`date +%H:%M:%S`
users=`users`
u=`for x in $users; do echo $x; done | sort | uniq`
sac -pb $hours $u -T $TTYS | while read user hours
do
if [ `expr $hours '<=' $MAXHOURS` -eq 1 ]; then
echo "$user is OK. ($hours)"
else
echo "$user is over the limit. ($hours)"
fi
done
# If you use Sac to implement usage limits, the above can be modified to
# "logout" the user by modifing the above if statement to the below:
#
# if [ `expr $h '<=' $MAXHOURS` -eq 0 ]; then
# echo "You're over the time limit bozo! ($h) Bye Bye!" | write $user
# ps augx | tail +2 | while read usr PID whatever
# do
# if [ $usr = $user ]; then kill -9 $PID; fi
# done
# fi
#
# Running this script every 5-10 minutes in a cron job wouldn't be a bad idea
# either.